import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import Mint from "mint-ui";
import "mint-ui/lib/style.css";
import VueVideoPlayer from "vue-video-player";
// require videojs style
import "video.js/dist/video-js.css";
import "vue-video-player/src/custom-theme.css";
import axios from "@/utils/interface.js";
import { Toast } from "mint-ui";
Vue.config.productionTip = false;
Vue.use(Mint);

Vue.prototype.$axios = axios;

Vue.use(
  VueVideoPlayer
  /* {
  options: ȫ������,
  events: ȫ�ֵ����¼�
} */
);

router.beforeEach((to, from, next) => {
  if (to.matched.some(m => m.meta.auth)) {
    // 对路由进行验证
    if (window.localStorage.isLogin === "1") {
      // 已经登陆
      // 正常跳转到你设置好的页面
      next();
    } else if (to.path !== "/") {
      // 未登录则跳转到登陆界面，query:{ Rurl: to.fullPath}表示把当前路由信息传递过去方便登录后跳转回来；
      //next({ path: "/Login", query: { Rurl: to.fullPath } });

      next({ path: "/Login" });
      Toast("检测到您还未登录,请登录后操作！");
    }
  } else {
    next();
  }
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
